package gold.contest;

import gold.utils.InputUtil;

import java.util.*;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC6100 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {

        int factor = 1000000007;
        Map<Integer, Long> memo = new HashMap<>();

        public int countHousePlacements(int n) {
            long fi = getKFiboRecursive(n);
            return (int) ((fi * fi) % factor);
        }

        public long getKFiboRecursive(int k) {
            if (k <= 2) return k + 1;
            if (memo.containsKey(k)) return memo.get(k);
            long val = getKFiboRecursive(k - 1) % factor + getKFiboRecursive(k - 2) % factor;
            memo.put(k, val);
            return val;
        }

        public long getKFiboReal(int k) {
            k += 2;
            double sqFive = Math.sqrt(5.0);
            return (long) ((Math.pow((1 + sqFive) / 2, k) - Math.pow((1 - sqFive) / 2, k)) / sqFive);
        }
    }

    public void run() {
//        System.out.println(new Solution().getKFibo(10000));
        System.out.println(new Solution().getKFiboRecursive(1000));
        System.out.println(new Solution().countHousePlacements(1000));
    }

    public static void main(String[] args) throws Exception {
        LC6100 an = new LC6100();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
